
class SocketWrapper():
    def __init__(self,sock):
        self.sock = sock

    #接收数据并解码
    def recv_data(self):
        try:
            data = self.sock.recv(1048).decode('utf-8')
        except Exception:
            return None
        return data

    #发送数据并编码
    def send_data(self,message):
        return self.sock.send(message.encode('utf-8'))

    def close(self):
        self.sock.close()